package org.bjtu.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.bjtu.Global;
import org.bjtu.model.Orgrole;
import org.bjtu.service.RoleManageService;

public class RoleManageAction extends DispatchAction {

	public ActionForward createRole(ActionMapping mapping,ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response){
		System.out.println("create role action");
		String roleName = request.getParameter("roleName");
		String roleDes = request.getParameter("roleDes");
		System.out.println("role name " + roleName + " ,role des " + roleDes);
		Orgrole role = new Orgrole();
		role.setOrgrname(roleName);
		role.setOrgrdescription(roleDes); 
		Global.getRoleManageService().saveOrUpdate(role);
//		if(new RoleManageService().createRole(roleName, roleDes))
		return mapping.findForward("list");
//		else
//			return "error";
	}

}
